package com.kx.yooli.kx.wechat.utils.message;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author john_sqwen-childe.wen
 * @date 2024/4/2
 * @PROJECT_NAME wechat
 * @description create MessageUtils by john_sqwen
 * and  value is
 */
public class MessageUtil {
    private final Logger log = LoggerFactory.getLogger(MessageUtil.class);


    protected static String PREFIX_CDATA    = "<![CDATA[";
    protected static String SUFFIX_CDATA    = "]]>";

    public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";

    /**

     * 返回消息类型：文本

     */

    public static final String RESP_MESSAGE_TYPE_TEXT = "text";

    /**

     * 返回消息类型：音乐

     */

    public static final String RESP_MESSAGE_TYPE_MUSIC = "music";

    /**

     * 返回消息类型：图文

     */

    public static final String RESP_MESSAGE_TYPE_NEWS = "news";

    /**

     * 请求消息类型：文本

     */

    public static final String REQ_MESSAGE_TYPE_TEXT = "text";

    /**

     * 请求消息类型：图片

     */

    public static final String REQ_MESSAGE_TYPE_IMAGE = "image";

    /**

     * 请求消息类型：链接

     */

    public static final String REQ_MESSAGE_TYPE_LINK = "link";

    /**

     * 请求消息类型：地理位置

     */

    public static final String REQ_MESSAGE_TYPE_LOCATION = "location";

    /**

     * 请求消息类型：音频

     */

    public static final String REQ_MESSAGE_TYPE_VOICE = "voice";

    /**

     * 请求消息类型：推送

     */

    public static final String REQ_MESSAGE_TYPE_EVENT = "event";

    /**

     * 事件类型：subscribe(订阅)

     */

    public static final String EVENT_TYPE_SUBSCRIBE = "subscribe";

    /**

     * 事件类型：unsubscribe(取消订阅)

     */

    public static final String EVENT_TYPE_UNSUBSCRIBE = "unsubscribe";

    /**

     * 事件类型：scan(扫描事件)

     */

    public static final String EVENT_TYPE_SCAN = "SCAN";

    /**

     * 事件类型：CLICK(自己定义菜单点击事件)

     */

    public static final String EVENT_TYPE_CLICK = "CLICK";

    /*
     * 事件类型：MASSSENDJOBFINISH(微信群发)
     * */
    public static final String MASSSENDJOBFINISH = "MASSSENDJOBFINISH";

    /**

     * 文本消息对象转换成xml

     *

     * @param textMessage 文本消息对象

     * @return xml

     */

//    public static   String textMessageToXml(TextMessage textMessage) {
//    	 XStream xstream=new XStream();
//        xstream.alias("xml", textMessage.getClass());
//
//        return xstream.toXML(textMessage);
//
//    }
    /**

     * 音乐消息对象转换成xml

     *

     * @param musicMessage 音乐消息对象

     * @return xml

     */

//    public  String musicMessageToXml(MusicMessage musicMessage) {
//
//        xstream.alias("xml", musicMessage.getClass());
//
//        return xstream.toXML(musicMessage);
//
//    }
    /**

     * 图文消息对象转换成xml

     * @param newsMessage 图文消息对象

     * @return xml

     */

//    public static   String newsMessageToXml(NewsMessage newsMessage) {
//
//        xstream.alias("xml", newsMessage.getClass());
//
//        xstream.alias("item", new Article().getClass());
//        return xstream.toXML(newsMessage);
//
//    }

//    public static void main(String[] args) {
//    	TextMessage test=new TextMessage();
//    	test.setContent("test");
//
//	}

    public static String handleMessageByCData(String str){
        return PREFIX_CDATA+str+SUFFIX_CDATA;
    }
}
